#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
<!DOCTYPE html>
<html>
<head>
    <title>Bootstrap Password Strength Meter Custom Rules Example</title>
    <link rel="stylesheet" media="screen" href="bootstrap.css" />
</head>
<body>
    <form>
        <fieldset>
            <legend>Please type in your password</legend>
            User: <input type="text" id="username" /><br />
            Pass: <input type="password" id="password" />
        </fieldset>
    </form>
    <p>Emails and the words "password", "god" and "123456" have been blocked by
    the custom rules. So if you try an email or the password contains one of
    the blocked words, then the password will be marked as weak.</p>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript" src="pwstrength.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(function () {
            "use strict";
            var ${symbol_dollar}password = ${symbol_dollar}(':password').pwstrength(),
                common_words = ["password", "god", "123456"];

            ${symbol_dollar}password.pwstrength("addRule", "notEmail", function (options, word, score) {
                return word.match(/^([${symbol_escape}w${symbol_escape}!${symbol_escape}${symbol_pound}${symbol_dollar}${symbol_escape}%${symbol_escape}&${symbol_escape}'${symbol_escape}*${symbol_escape}+${symbol_escape}-${symbol_escape}/${symbol_escape}=${symbol_escape}?${symbol_escape}^${symbol_escape}`{${symbol_escape}|${symbol_escape}}${symbol_escape}~]+${symbol_escape}.)*[${symbol_escape}w${symbol_escape}!${symbol_escape}${symbol_pound}${symbol_dollar}${symbol_escape}%${symbol_escape}&${symbol_escape}'${symbol_escape}*${symbol_escape}+${symbol_escape}-${symbol_escape}/${symbol_escape}=${symbol_escape}?${symbol_escape}^${symbol_escape}`{${symbol_escape}|${symbol_escape}}${symbol_escape}~]+@((((([a-z0-9]{1}[a-z0-9${symbol_escape}-]{0,62}[a-z0-9]{1})|[a-z])${symbol_escape}.)+[a-z]{2,6})|(${symbol_escape}d{1,3}${symbol_escape}.){3}${symbol_escape}d{1,3}(${symbol_escape}:${symbol_escape}d{1,5})?)${symbol_dollar}/i) && score;
            }, -100, true);

            ${symbol_dollar}password.pwstrength("addRule", "commonWords", function (options, word, score) {
                var result = false;
                ${symbol_dollar}.each(common_words, function (i, item) {
                    var re = new RegExp(item, "gi");
                    if (word.match(re)) {
                        result = score;
                    }
                });
                return result;
            }, -500, true);
        });
    </script>
</body>
</html>
